//
//  SingleInstance.h
//
//  Created by LeungChaos on 16/5/14.
//  Copyright © 2016年 liang. All rights reserved.
//

/**
 * 单例宏
 */
#define SingleInstance_h(Class) + (Class *)shared##Class;

#define SingleInstance_m(Class) static id _instance;\
+ (Class *)shared##Class\
{\
    static dispatch_once_t onceToken;\
    dispatch_once(&onceToken, ^{\
    _instance = [[self alloc] init];\
    });\
    return _instance;\
}\
+ (id)allocWithZone:(struct _NSZone *)zone\
{\
    static dispatch_once_t onceToken;\
    dispatch_once(&onceToken, ^{\
        _instance = [super allocWithZone:zone];\
    });\
    return _instance;\
}\
- (id)copyWithZone:(NSZone *)zone\
{\
    return _instance;\
}\
- (id)mutableCopyWithZone:(NSZone *)zone\
{\
    return _instance;\
}
